package com.letoken.platform.app.dataCacheService;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.letoken.platform.repo.sss.dao.AdminTokenConfigMapper;
import com.letoken.platform.repo.sss.po.AdminTokenConfig;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class InitializationData implements ApplicationListener<ContextRefreshedEvent> {
    @Resource
    AdminTokenConfigMapper adminTokenConfigMapper;

    private List<AdminTokenConfig> cacheAdminTokenConfigs;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        this.cacheAdminTokenConfigs = adminTokenConfigMapper.selectList(new QueryWrapper<AdminTokenConfig>().orderByAsc("id"));
    }

    public List<AdminTokenConfig> getCachedData() {
        return cacheAdminTokenConfigs;
    }
}
